function Girl(option) {
    this._init(option)
}
Girl.prototype = {
    constructor:Girl,
    //初始化
    _init:function (option) {
        option = option || {};
        this.imgSrc = option.imgSrc;

        this.clipW = option.clipW || 256;
        this.clipH = option.clipH || 256;

        this.x = option.x || 100;
        this.y = option.y || 100;

        this.width = option.width || 256;
        this.height = option.height || 256;

        this.duration = option.duration || 300;
        this.dir = option.dir || 0;
    },
    render:function (ctx) {
        var self = this;
        var image = new Image();
        image.src = this.imgSrc;
        var index = 0;
        image.onload = function () {
            setInterval(function () {
                ctx.clearRect(self.x,self.y,self.width,self.height);
                ctx.drawImage(image,index*self.clipW,self.clipH*self.dir,self.clipW,self.clipH,self.x,self.y,self.width,self.height);
                index++;
                index %= 8;
            },self.duration)
        }
    },
    changeDir:function (dir) {
        this.dir = dir;
    }
};